#include <iostream>
#include <string>
#include <sstream>

using namespace std;


int main()
{
	int largest = 0;

	for (int num1 = 100; num1 < 1000; ++num1)
	{
		for (int num2 = 100; num2 < 1000; ++num2)
		{
			unsigned int product = num1 * num2;

			stringstream line;
			line << product;
			int length = line.str().length();
			string part1 = line.str().substr(0, length/2);
			string part2 = line.str().substr(length/2, length/2);
			bool palindrome = true;
			int halfLength = length/2;
			for (int num = 0; num < part1.length(); ++num)
			{
				if (part1[num] != part2[halfLength - num - 1])
				{
					palindrome = false;
					break;
				}
			}

			if (palindrome)
			{
				if (product > largest)
				{
					largest = product;
				}

				cout << line.str().c_str() << endl;
			}
		}
	}

	cout << "Largest: " << largest << endl;
}